/* 
 *  Copyright (C) 2009-2010 milkyjing <milkyjing@gmail.com>
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */

#include "file.h"
#include "text.h"
#include "image.h"
#include "utility.h"
#include "tcsfunc.h"


static PyMethodDef tcxLib_Methods[] = {
    /* in pix.h */
    { "BlankPix"          ,  tcxlib_create_blank_pix               ,  METH_VARARGS ,  "BlankPix(width, height, rgba)" },
    { "PixResize"         ,  tcxlib_resample_py_pix                ,  METH_VARARGS ,  "PixResize(PIX, width, height)" },
    { "PixEnlarge"        ,  tcxlib_enlarge_py_pix                 ,  METH_VARARGS ,  "PixEnlarge(PIX, x, y)" },
    { "PixCrop"           ,  tcxlib_crop_py_pix                    ,  METH_VARARGS ,  "PixCrop(PIX, left, top, right, bottom)" },
    { "PixTexture"        ,  tcxlib_apply_pix_texture              ,  METH_VARARGS ,  "PixTexture(PIX, texture)" },
    { "PixMask"           ,  tcxlib_apply_pix_mask                 ,  METH_VARARGS ,  "PixMask(PIX, mask)" },
    { "PixBlur"           ,  tcxlib_apply_gauss_blur               ,  METH_VARARGS ,  "PixBlur(PIX, radius)" },
    { "CombinePixs"       ,  tcxlib_combine_two_pixs               ,  METH_VARARGS ,  "CombinePixs(back, overlay)" },
    { "PixColorMul"       ,  tcxlib_pix_color_multiply             ,  METH_VARARGS ,  "PixColorMul(PIX, r_f, g_f, b_f, a_f)" },
    { "PixColorShift"     ,  tcxlib_pix_color_shift                ,  METH_VARARGS ,  "PixColorShift(PIX, r, g, b, a)" },
    { "PixColorTrans"     ,  tcxlib_pix_color_transparent          ,  METH_VARARGS ,  "PixColorTrans(PIX, rgb)" },
    { "PixColorRGBA"      ,  tcxlib_pix_color_flat_rgba            ,  METH_VARARGS ,  "PixColorRGBA(PIX, rgba)" },
    { "PixColorRGB"       ,  tcxlib_pix_color_flat_rgb             ,  METH_VARARGS ,  "PixColorRGB(PIX, rgb)" },
    { "PixColorA"         ,  tcxlib_pix_color_flat_alpha           ,  METH_VARARGS ,  "PixColorA(PIX, alpha)" },
    { "BilinearFilter"    ,  tcxlib_bilinear_filter                ,  METH_VARARGS ,  "BilinearFilter(PIX, offset_x, offset_y)" },
    { "InitBigPix"        ,  tcxlib_init_big_pix                   ,  METH_VARARGS ,  "InitBigPix()" },
    { "BigPixAdd"         ,  tcxlib_big_pix_add                    ,  METH_VARARGS ,  "BigPixAdd(BIG_PIX, PIX, offset_x, offset_y, layer)" },
    { "ConvertBigPix"     ,  tcxlib_convert_big_pix                ,  METH_VARARGS ,  "ConvertBigPix(BIG_PIX)" },
    /* in file.h */
    { "CreateAssFile"     ,  tcxlib_create_ass_file                ,  METH_VARARGS ,  "CreateAssFile(ass_file, ass_header)" },
    { "WriteAssFile"      ,  tcxlib_write_ass_file                 ,  METH_VARARGS ,  "WriteAssFile(pyAssFile, ASS_BUF)" },
    { "FinAssFile"        ,  tcxlib_fin_ass_file                   ,  METH_VARARGS ,  "FinAssFile(pyAssFile)" },
    { "CreateTcsFile"     ,  tcxlib_create_tcs_file                ,  METH_VARARGS ,  "CreateTcsFile(tcs_file, fx_width, fx_height, fx_fps)" },
    { "WriteTcsFile"      ,  tcxlib_write_tcs_file                 ,  METH_VARARGS ,  "WriteTcsFile(pyTcsFile, TCS_BUF)" },
    { "FinTcsFile"        ,  tcxlib_fin_tcs_file                   ,  METH_VARARGS ,  "FinTcsFile(pyTcsFile)" },
    /* in text.h */
    { "InitFont"          ,  tcxlib_init_py_font                   ,  METH_VARARGS ,  "InitFont(font_file, face_id, font_size, spacing, space_scale, color, bord, is_outline)" },
    { "FinFont"           ,  tcxlib_fin_py_font                    ,  METH_VARARGS ,  "FinFont(pyFont)" },
    { "TextPix"           ,  tcxlib_get_pix_from_text              ,  METH_VARARGS ,  "TextPix(pyFont, text) or TextPix(font_file, face_id, font_size, spacing, space_scale, color, bord, is_outline, text)" },
    { "TextMetrics"       ,  tcxlib_get_text_metrics               ,  METH_VARARGS ,  "TextMetrics(pyFont, text) or TextMetrics(font_file, face_id, font_size, spacing, space_scale, text)" },
    /* in image.h */
    { "ImagePix"          ,  tcxlib_get_pix_from_image             ,  METH_VARARGS ,  "ImagePix(filename) or ImagePix(filename, width, height)" },
    { "SavePix"           ,  tcxlib_save_pix_to_image              ,  METH_VARARGS ,  "SavePix(filename, PIX) or SavePix(filename, PIX, width, height)" },
    /* in utility.h */
    { "IsCjk"             ,  tcxlib_is_c_or_j_or_k                 ,  METH_VARARGS ,  "IsCjk(text)" },
    { "VertLayout"        ,  tcxlib_vertical_layout_ass            ,  METH_VARARGS ,  "VertLayout(text)" },
    { "ShowProgress"      ,  tcxlib_show_progress                  ,  METH_VARARGS ,  "ShowProgress(total, completed, file_id, file_num)" },
    /* in tcsfunc.h */
    { "tcs_main"          ,  tcxlib_tcs_list_append_pix            ,  METH_VARARGS ,  "tcs_main(TCS_BUF, pix, start, end, offsetX, offsetY, layer)" },
    { "tcs_fade"          ,  tcxlib_tcs_list_append_pix_with_fade  ,  METH_VARARGS ,  "tcs_fade(TCS_BUF, pix, start, end, t1, t2, fps, offsetX, offsetY, layer)" },
    { NULL                ,  NULL                                  ,  0            ,  NULL }
};

static struct PyModuleDef tcxLib_Module = {
    PyModuleDef_HEAD_INIT, 
    "tcxLib", 
    "Module tcxLib is a component of tcxCore", 
    -1, 
    tcxLib_Methods
};

PyMODINIT_FUNC PyInit_tcxLib() {
    return PyModule_Create(&tcxLib_Module);
}

